import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;

public class GameManager {
    private Stage primaryStage;
    private GameScene gameScene;
    private MainMenu mainMenu;
    private GameOverScene gameOverScene;
    private SettingsScene settingsScene;

    public GameManager(Stage primaryStage) {
        this.primaryStage = primaryStage;
        primaryStage.setTitle("俄罗斯方块");
        primaryStage.setResizable(false);
        
        // 初始化各个场景
        gameScene = new GameScene(this);
        mainMenu = new MainMenu(this);
        gameOverScene = new GameOverScene(this);
        settingsScene = new SettingsScene(this);
    }

    public void showMainMenu() {
        Scene scene = mainMenu.createScene();
        primaryStage.setScene(scene);
        primaryStage.show();
    }

    public void startGame() {
        Scene scene = gameScene.createScene();
        primaryStage.setScene(scene);
        primaryStage.show();
        gameScene.startGame();
    }

    public void showGameOver(int score) {
        Scene scene = gameOverScene.createScene(score);
        primaryStage.setScene(scene);
        primaryStage.show();
    }

    public void showSettings() {
        Scene scene = settingsScene.createScene();
        primaryStage.setScene(scene);
        primaryStage.show();
    }

    public void applySettings(int width, int height, int initialSpeed) {
        gameScene.setBoardDimensions(width, height);
        gameScene.setInitialSpeed(initialSpeed);
    }
}
